#include<YLFW/Shader.h>
#include<YLFW/VertexObject.h>
#include<YLFW/YLFWTexture.h>
#include<YLFW/YLFWWindow.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
static int TestMain() {
	YLFWWindow* window = YLFWWindow::CreateWindow(800,600,"Transformations");
	Shader shader("Assets/Shaders/transformations.vs", "Assets/Shaders/transformations.fs");
	float vertices[] = {
		0.5f,0.5f,0.0f,1.0f,1.0f,
		0.5f,-0.5f,0.0f,1.0f,0.0f,
		-0.5f,-0.5f,0.0f,0.0f,0.0f,
		-0.5f,0.5f,0.0f,0.0f,1.0f,
	};
	unsigned int indices[] = {
		0,1,3,
		1,2,3
	};
	VertexObject vertexObject(vertices,sizeof(vertices),indices,sizeof(indices));
	YLFWTexture texture("Assets/Images/awe.jpg");
	
	float currentTime = (float)glfwGetTime();
	while (!window->IsClose()) {
		if (window->GetKey(GLFW_KEY_ESCAPE)) {
			window->Close();
		}
		window->Clear();
		float deltaTime = glfwGetTime() - currentTime;
		currentTime = glfwGetTime();
		glm::mat4 transform = glm::mat4(1.0f);
		transform = glm::translate(transform, glm::vec3(0.5f, -0.5f, 0.0f));
		transform = glm::rotate(transform, currentTime, glm::vec3(0.0f, 0.0f, 1.0f));
		shader.setMatrix4fv("transform",transform);

		window->DrawTriangles(shader,vertexObject,texture);

		transform = glm::mat4(1.0f);
		transform = glm::translate(transform, glm::vec3(-0.5f, 0.5f, 0.0f));
		float scaleAmount = cos(glfwGetTime());
		transform = glm::scale(transform, glm::vec3(scaleAmount, scaleAmount, scaleAmount));
		shader.setMatrix4fv("transform",transform);

		window->DrawTriangles(shader, vertexObject, texture);

		window->SwapBuffers();
		window->PullEvent();
	}
	delete window;
	YLFWWindow::Terminate();
	return 0;
}